package cn.parus.controller;

import cn.parus.common.Execption.Result;
import cn.parus.entity.FileOperation;
import cn.parus.service.FileOperationService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: Axel
 * @Description: TODO
 **/
@RestController
@RequestMapping("/file-operation")
public class FileOperationController {

    @Autowired
    private FileOperationService fileOperationService;

    /**
     * 查询文件操作记录
     * @param operationType 操作类型
     * @param current 当前页
     * @param size 每页数量
     * @return 分页数据 TODO 当前查询条件错误
     */
    @GetMapping("/operations")
    public Result searchFileOperations(
            @RequestParam(value = "operationType", required = false) String operationType,
            @RequestParam(defaultValue = "1") Integer current,
            @RequestParam(defaultValue = "10") Integer size) {
        Page<FileOperation> operations = fileOperationService.searchFileOperation(operationType, current, size);
        return Result.success(operations);
    }
}
